<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>登录</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    <link rel="shortcut icon" th:href="@{~/UI/favicon.ico}" type="image/x-icon" />
    <link rel="stylesheet" th:href="@{~/UI/css/font.css}">
    <link rel="stylesheet" th:href="@{~/UI/css/xadmin.css}">

    <script th:src="@{~/UI/js/jquery.min.js}"></script>
    <script th:src="@{~/UI/lib/layui/layui.js}"></script>
    <script type="text/javascript" th:src="@{~/UI/js/xadmin.js}"></script>

</head>
<body class="login-bg" style="background-image: url(/images/login-bg-001.jpg); background-size: cover;">

    <div class="login layui-anim layui-anim-up"><br>
        <div><center><h2>登录</h2></center></div>
        <div id="darkbannerwrap"></div><br>

        <div class="layui-form" >
            <div class="layui-form-item">
                <input name="uname" id="uname" placeholder="用户名"  type="text" lay-verify="required" class="layui-input">
            </div>
            <hr class="hr15">
            <div class="layui-form-item">
                <input name="upassword" id="upassword" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            </div>
            <hr class="hr15">
            <div class="layui-form-item">
                <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
            </div>
            <center><a th:href="@{/toUserInsert}">注册</a></center>
            <hr class="hr20" >
        </div>
    </div>

    <script>
        $(function  () {
            layui.use('form', function(){
                var form = layui.form;
                // layer.msg('玩命卖萌中', function(){
                //   //关闭后的操作
                //   });
                //监听提交
                form.on('submit(login)', function(data){

                    var uname = $("#uname").val();
                    var upassword = $("#upassword").val();
                    $.ajax({
                        type: "post",
                        url: "/userLogin",
                        dataType: "json",
                        data: {'uname':uname,'upassword':upassword},
                        success: function (data) {
                            // alert(data);
                            if (data == 1 || data ==2) {
                                //跳转页面
                                window.open("toMain",'_parent');
                            } else {
                                layer.msg("用户名或密码错误");
                            }
                        }
                    });

                });
            });
        })


    </script>

</body>
</html>